package cn.demoncat.util.lang.entity.data;

/**
 * 带权数据
 * 
 * @author 延晓磊
 *
 * @since 2020年7月25日
 */
public class WeightData<E,W extends Comparable<W>> implements Comparable<WeightData<E,W>>{
	
	// 数据
	private E data;
	// 权值
	private W weight;
	
	public WeightData() {
		super();
	}

	public WeightData(E data) {
		super();
		this.data = data;
	}
	
	public WeightData(E data, W weight) {
		super();
		this.data = data;
		this.weight = weight;
	}

	/**
	 * 数据
	 * 
	 * @return
	 * 
	 * @author 延晓磊
	 *
	 * @since 2020年7月25日
	 */
	public E getData() {
		return data;
	}

	public void setData(E data) {
		this.data = data;
	}

	/**
	 * 权值
	 * 
	 * @return
	 * 
	 * @author 延晓磊
	 *
	 * @since 2020年7月25日
	 */
	public W getWeight() {
		return weight;
	}

	public void setWeight(W weight) {
		this.weight = weight;
	}

	@Override
	public String toString() {
		return "{data : " + data + ", weight : " + weight + "}";
	}

	@Override
	public int compareTo(WeightData<E, W> o) {
		return this.weight.compareTo(o.weight);
	}
	
}
